/**
 * @param {number[]} arr
 * @return {boolean}
 */
export var canMakeArithmeticProgression = function (arr) {
  if (arr.length == 2) return true
  arr.sort((a, b) => a - b)
  const diff = arr[1] - arr[0]
  for (let i = 2; i < arr.length; i++) {
    if (arr[i] - arr[i - 1] !== diff) {
      return false
    }
  }
  return true
}

export var canMakeArithmeticProgression2 = function (arr) {
  if (arr.length == 2) return true
  arr.sort((a, b) => a - b)
  for (let i = 1; i < arr.length - 1; i++) {
    if (arr[i] * 2 !== arr[i + 1] + arr[i - 1]) {
      return false
    }
  }
  return true
}
